//
//  EzvizRoute.m
//  ocdemo
//
//  Created by mac on 2025/10/12.
//

#import "EzvizRoute.h"

#import "ReactController.h"
#import "NavigationHelper.h"
@implementation EzvizRoute
RCT_EXPORT_MODULE()
- (dispatch_queue_t)methodQueue {
    return dispatch_get_main_queue();
}
RCT_EXPORT_METHOD(startReactNative:(NSString* )biz andEntry:(NSString*)entry andParams:(NSDictionary *)dict){
    
    //1. dict
    NSMutableDictionary *dic=[NSMutableDictionary dictionaryWithDictionary:dict];
    [dic setValue:entry forKey:@"entry"];
    
    //2. vc
    ReactController *vc=[[ReactController alloc]initWithURL:@"" path:[NSString stringWithFormat:@"%@.jsbundle",biz] type:InApp moduleName:[NSString stringWithFormat:@"%@",biz] initialProperties:dic];
    //2.1 nav
    UINavigationController *navvc=[NavigationHelper topNavViewController];
    //3.push
    [navvc pushViewController:vc animated:YES];
    [navvc hidesBottomBarWhenPushed];
    
}


RCT_EXPORT_METHOD(popViewControllerAnimated:(BOOL)animated){
    [NavigationHelper popViewControllerAnimated:animated];
}
RCT_EXPORT_METHOD(popToRootViewControllerAnimated:(BOOL)animated){
    [NavigationHelper popToRootViewControllerAnimated:animated];
}
RCT_EXPORT_METHOD(popToViewController:(UIViewController *)viewController animated:(BOOL)animated){
    [NavigationHelper popToViewController:viewController animated:animated];
}
RCT_EXPORT_METHOD(canPopViewController){
    [NavigationHelper canPopViewController];
}
RCT_EXPORT_METHOD(selectTabWithIndex:(NSInteger)index){
    [NavigationHelper selectTabWithIndex:index];
}
+ (BOOL)requiresMainQueueSetup
{
  return YES;
}

@end
